<template>
  <div class="school">
    <h1>学生名称：{{ name }}</h1>
    <h1>学生年龄：{{ age }}</h1>
    <button @click="send">点我把数据传递给兄弟组件Student</button>
  </div>
</template>

<script>
import pubsub from "pubsub-js"

export default {
  name: "Student",
  data() {
    return {
      name: "陶品奇",
      age: 22,
    }
  },
  methods: {
    send() {
      //发布消息
      pubsub.publish("getData", {name: this.name, age: this.age})
    }
  }
};
</script>

<style>
.school {
  background-color: #15e79e;
}
</style>
